<?php 
session_start();
$_SESSION['debug'] = true;
if($_SESSION['debug']){
	$_SESSION['userdata']['username']= "admin";
	$_SESSION['userdata']['rank']= "4";
	$_SESSION['auth'] = true;
	$_SESSION['rule'] = "ADMIN";
}
if ($_SESSION['auth'] != true || $_SESSION['rule'] != "ADMIN") {
	$currUrl = 'http://' . $_SERVER['HTTP_HOST'] . rtrim(dirname($_SERVER['PHP_SELF']), '/\\');
	header("location:$currUrl/login.html");
	echo "please login.";
	echo "<br>redirecting...";
	exit();
}
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Admin</title>
<link href="itelement.css" rel="stylesheet" type="text/css" />
<script src="script/jquery.js" type=text/javascript></script>
<script src="script/admin.js" type=text/javascript></script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head>
<body>
<div class="itelement" id="header">IT Element </div>
<div class="main">
  <table id="main-table">
    <tr>
      <td width="1"><div class="nav" id="nav">
        <div class="nav-item">
          <table width="100%">
            <tr>
              <td><table width="100%">
                <tr>
                    <td id="channel-down" title="Collapse channel" onClick="$('#channel-container').toggle();" 
					style="vertical-align:middle;text-align:center" onMouseOver="this.style.backgroundColor='#bfd8ea'" 
					onMouseOut="this.style.backgroundColor=''"><img src="img/down.gif"></td>
                  <td class="nav-header">Channel</td>
                  <td style="text-align:right" align="right"><input name="button" type="button" 
					onClick="$('#main-right-box').attr('src','admin_add_channel.php');" value="add">					<input name="button2" type="button" onClick="searchChannel()" value="edit">					</td>
                </tr>
              </table></td>
            </tr>
            <tr>
              <td id="channel-container"><table>
                  <tr>
                    <td>title :</td>
                    <td><input name="text" type="text" id="channel-title" width="100%"></td>
                  </tr>
                  <tr>
                    <td>link :</td>
                    <td><input name="text" type="text" id="channel-link" width="100%"></td>
                  </tr>
                  <tr>
                    <td>rank :</td>
                    <td><input name="text" type="text" id="channel-rank" width="100%"></td>
                  </tr>
                </table>
                  <input name="button2" type="button" onClick="searchChannel()" value="search">
              </td>
            </tr>
          </table>
        </div>
        <div class="nav-item">
          <table width="100%">
            <tr>
              <td><table width="100%">
                <tr>
                    <td id="provider-down" title="Collapse provider" onClick="$('#provider-container').toggle();" 
					style="vertical-align:middle;text-align:center" onMouseOver="this.style.backgroundColor='#bfd8ea'" 
					onMouseOut="this.style.backgroundColor=''"><img src="img/down.gif"></td>
                  <td class="nav-header">Provider</td>
                  <td style="text-align:right" align="right"><input name="button2" type="button" onClick="$('#main-right-box').attr('src','admin_add_provider.php');" value="add">				  <input name="button2" type="button" onClick="searchProvider()" value="edit"> </td>
                </tr>
              </table></td>
            </tr>
            <tr>
              <td id="provider-container"><table>
                  <tr>
                    <td>username :</td>
                    <td><input name="text" type="text" id="provider-username" width="100%"></td>
                  </tr>
                  <tr>
                    <td>fname :</td>
                    <td><input name="text" type="text" id="provider-fname" width="100%"></td>
                  </tr>
                  <tr>
                    <td>lname :</td>
                    <td><input name="text" type="text" id="provider-lname" width="100%"></td>
                  </tr>
                  <tr>
                    <td>company :</td>
                    <td><input name="text" type="text" id="provider-company" width="100%"></td>
                  </tr>
                </table>
                  <input name="button2" type="button" onClick="searchProvider()" value="search">
              </td>
            </tr>
          </table>
        </div>
        <div class="nav-item">
          <table width="100%">
            <tr>
              <td><table width="100%">
                <tr>
                    <td id="publisher-down" title="Collapse publisher" onClick="$('#publisher-container').toggle();" 
					style="vertical-align:middle;text-align:center" onMouseOver="this.style.backgroundColor='#bfd8ea'" 
					onMouseOut="this.style.backgroundColor=''"><img src="img/down.gif"></td>
                  <td class="nav-header">Publisher</td>
                  <td style="text-align:right" align="right"><input name="button2" type="button" onClick="$('#main-right-box').attr('src','admin_add_publisher.php');" value="add">				  <input name="button2" type="button" onClick="searchPublisher()" value="edit"> </td>
                </tr>
              </table></td>
            </tr>
            <tr>
              <td id="publisher-container"><table>
                  <tr>
                    <td>username :</td>
                    <td><input name="text" type="text" id="publisher-username" width="100%"></td>
                  </tr>
                  <tr>
                    <td>fname :</td>
                    <td><input name="text" type="text" id="publisher-fname" width="100%"></td>
                  </tr>
                  <tr>
                    <td>lname :</td>
                    <td><input name="text" type="text" id="publisher-lname" width="100%"></td>
                  </tr>
                  <tr>
                    <td>company :</td>
                    <td><input name="text" type="text" id="publisher-company" width="100%"></td>
                  </tr>
                </table>
                  <input name="button2" type="button" onClick="searchPublisher()" value="search">
              </td>
            </tr>
          </table>
        </div>
        <div class="nav-item">
          <table width="100%">
            <tr>
              <td><table width="100%">
                <tr>
                    <td id="reader-down" title="Collapse reader" onClick="$('#reader-container').toggle();" 
					style="vertical-align:middle;text-align:center" onMouseOver="this.style.backgroundColor='#bfd8ea'" 
					onMouseOut="this.style.backgroundColor=''"><img src="img/down.gif"></td>
                  <td class="nav-header">Reader</td>
                  <td style="text-align:right" align="right" ><input name="button2" type="button" onClick="$('#main-right-box').attr('src','admin_add_reader.php');" value="add">				  <input name="button2" type="button" onClick="searchReader()" value="edit"> </td>
                </tr>
              </table></td>
            </tr>
            <tr>
              <td id="reader-container"><table>
                  <tr>
                    <td>username :</td>
                    <td><input name="text" type="text" id="reader-username" width="100%"></td>
                  </tr>
                  <tr>
                    <td>fname :</td>
                    <td><input name="text" type="text" id="reader-fname" width="100%"></td>
                  </tr>
                  <tr>
                    <td>lname :</td>
                    <td><input name="text" type="text" id="reader-lname" width="100%"></td>
                  </tr>
                  <tr>
                    <td>company :</td>
                    <td><input name="text" type="text" id="reader-company" width="100%"></td>
                  </tr>
                </table>
                  <input name="button2" type="button" onClick="searchReader()" value="search">
              </td>
            </tr>
          </table>
        </div>
        <div class="nav-item">
          <table width="100%">
            <tr>
              <td id="log-container"><table width="100%">
                  <tr>
                    <td id="log-down" title="Collapse log" 
					style="vertical-align:middle;text-align:center" onMouseOver="this.style.backgroundColor='#bfd8ea'" 
					onMouseOut="this.style.backgroundColor=''"><img src="img/down.gif"></td>
                    <td class="nav-header">Log</td>
                    <td style="text-align:right"><input name="button2" type="button" onClick="$('#main-right-box').attr('src','readLog.php');" value="View">
                      <input name="button22" type="button" onClick="$('#main-right-box').attr('src','editLog.php');" value="Edit"></td>
                  </tr>
              </table></td></tr>
          </table>
        </div>
      </div></td>
      <td id="expand" style="height:1000" width="3" style="background-color:#E6E9EE;vertical-align:middle;display:none" onMouseOver="this.style.backgroundColor='#CFCED2'" onMouseOut="this.style.backgroundColor='#E6E9EE'" onClick="ToggleCollapse()" title="Expand pane"><img src="img/expand.gif" /></td>
      <td id="collapse" style="height:1000" width="3" style="background-color:#E6E9EE;vertical-align:middle" onMouseOver="this.style.backgroundColor='#CFCED2'" onMouseOut="this.style.backgroundColor='#E6E9EE'" onClick="ToggleCollapse()" title="Collapse pane"><img src="img/collapse.gif" /></td>
      <td>
	  <iframe height="100%" width="100%" id="main-right-box" frameborder="0" src="admin_add_provider.php"></iframe>
	  </td>
    </tr>
  </table>
</div>
</body>
</html>
<script language="javascript" type="text/javascript">
var is_collapsed = false;
function ToggleCollapse()
{
    if (is_collapsed) { 
        document.getElementById("nav").style.display = '';
        document.getElementById("collapse").style.display = "";
        document.getElementById("expand").style.display = 'none';
        is_collapsed = false;
    } else {
        document.getElementById("nav").style.display = 'none';
        document.getElementById("collapse").style.display = "none";
        document.getElementById("expand").style.display = '';
        is_collapsed = true;
    }
}
function searchChannel(){
	var t = $('#channel-title').val();
	var l = $('#channel-link').val();
	var r = $('#channel-rank').val();
	$('#main-right-box').attr('src', "search_channel.php?title="+t+"&link="+l+"&rank="+r);
}
function searchProvider(){
	var u = $('#provider-username').val();
	var f = $('#provider-fname').val();
	var l = $('#provider-lname').val();
	var c = $('#provider-company').val();
	$('#main-right-box').attr('src', "search_provider.php?username="+u+"&fname="+f+"&lname="+l+"&company="+c);
}
function searchPublisher(){
	var u = $('#publisher-username').val();
	var f = $('#publisher-fname').val();
	var l = $('#publisher-lname').val();
	var c = $('#publisher-company').val();
	$('#main-right-box').attr('src', "search_publisher.php?username="+u+"&fname="+f+"&lname="+l+"&company="+c);
}
function searchReader(){
	var u = $('#reader-username').val();
	var f = $('#reader-fname').val();
	var l = $('#reader-lname').val();
	var c = $('#reader-company').val();
	$('#main-right-box').attr('src', "search_reader.php?username="+u+"&fname="+f+"&lname="+l+"&company="+c);
}
</script>